import { reactive, ref } from 'vue'
import { isComment } from 'element-plus/es/utils'
const pageData = reactive({
    query: {
      pageNo: 1,
      pageSize: 30,
      product_name: undefined,
      supplierName: undefined,
      brand_or_style: undefined,
    },
    //供应商列表请求
    supplierQuery: {
      pageNo: 1,
      pageSize: 10,
      supplierName: undefined,
      legalPerson: undefined,
      authorizer: undefined,
    },
    //成本表单列表请求
    costQuery: {
      pageNo: 1,
      pageSize: 30,
      product_name: undefined,
      supplierName: undefined,
    },
    //供应商表单
    initSupplierData:{
      basicInf:{
        supplierName: null,
        proAndSer: null,
      },
      enterpriseProfile:{
        address: null,
        establishmentDate: null,
        registeredCapital: null,
        legalPerson: null,
        legalPersonPhone: null,
        faxNumber: null,
        authorizer: null,
        position: null,
        authorizerPhone: null,
        website: null,
        businessModel: null,
        enterpriseNature: null,
        natureOfTaxpayer: null,
        registrationNumber: null,
        receivingParty: null,
        receivingBank: null,
        receivableAccount: null,
        legalDisputes: null,
      },
      organizationOrInstitution:{
        totalNumberOfEmployees: null,
        managers: null,
        technician: null,
        marketers: null,
        administrator: null,
        worker: null,
      },
      mainAchievements:{
        annual1: null,
        turnover1: null,
        annual2: null,
        turnover2: null,
        annual3: null,
        turnover3: null,
        annualSupplyCapacity: null,
        serviceAreaScope: null,
        quantityAndScale: null,
      }
    },
    //批次采购表单
    initPurchase:{
      id:null, //后端提供
      idealNum: null,
      activeIndex: 1, //0-普通录入；1-快捷录入
      type: null, //产品种类 1-原料，2-产品，3-其他
      is_quantity_based: 1, //计价是否按数量 0-按重量 1-按数量
      isSpecificationType:1, //规格类别 1-7类
      product_name: null,
      brand_or_style: null,
      internal_brand: null,
      productQuantity: null,
      productWeight: null,
      priceUnit: null, //计价单位
      weightUnit: null, //计量单位（重量）
      quantityUnit: null, //计量单位（数量）
      unit_price: null,
      productSum: null,
      description: null,
      supplierName: null,
      board:[],
      pipe:[],
      stick:[],
      Lens:[],
      ring:[],
      needle:[],
      purchaseTime: null, //批次采购时间
      specification: null,
    },
    //业务表单
    initBusinessData:{
      id:null, //后端提供
      type: null, //产品种类 1-原料，2-产品，3-其他
      is_quantity_based: 1, //计价是否按数量 0-按重量 1-按数量
      isSpecificationType:1, //规格类别 1-7类
      product_name: null,
      brand_or_style: null,
      internal_brand: null,
      totalProductQuantity: null,
      totalProductWeight: null,
      priceUnit: null, //计价单位
      weightUnit: null, //计量单位（重量）
      quantityUnit: null, //计量单位（数量）
      unit_price: null,
      totalProductSum: null, //合同签订总价
      board:[],
      pipe:[],
      stick:[],
      Lens:[],
      ring:[],
      needle:[],
      boardJson: null,
      pipeJson: null,
      stickJson: null,
      lensJson: null,
      ringJson: null,
      needleJson: null,
      signingDate: null, //签订时间
      validityPeriod: null, //有效期
      costRate: null, //单位产品库存年维持费用率
      specification: null,
    },
    //采购成本管理表单
    initCostformData:{
      id:null,
      supplierName: null,
      product_name: null,
      orderProcessingCost: 0,
      transportationFee: 0,
      insuranceFee: 0,
      telephoneFee: 0,
      inspectionFee: 0,
      loadingAndUnloadingFee: 0,
      otherFee: 0,
      totalFee: 0,
      note:[],
    },
    //入库单位换算用
    unitConversion:{
      amount:null,//重量
      piece:null,//数量
      unitPrice:null,//单价
    },
    //判断是否入库
    ifInBound: [],
    //采购表单验证
    rules: {
      supplierName: [
        { required: true, message: '请输入供应商名称', trigger: 'blur' },
      ],
      product_name: [
        { required: true, message: '请输入产品名称', trigger: 'blur' },
      ],
      // brand_or_style: [
      //   { required: true, message: '请输入产品外部款式或牌号', trigger: 'change' },
      // ],
      // internal_brand: [
      //   { required: true, message: '请输入产品内部款式或牌号', trigger: 'change' },
      // ],
      unit_price:[
        { required: true, message: '请输入采购的商品单价', trigger: 'change' },
      ],
      is_quantity_based:[
        { required: true, message: '请选择计价方式', trigger: 'change' },
      ],
      type:[
        { required: true, message: '请选择产品类别', trigger: 'change' },
      ],
    },
    //供应商表单验证：
    supplierRules:{
      // 基本信息验证规则
      basicInf: {
        supplierName: [{ required: true, message: '请输入供应商名称', trigger: 'blur' }],
      },
      // 企业概况验证规则
      enterpriseProfile: {
        address: [{ required: true, message: '请输入公司地址', trigger: 'blur' }],
        legalPerson: [{ required: true, message: '请输入法人代表', trigger: 'blur' }],
        legalPersonPhone: [{ pattern: /^1[3-9]\d{9}$/, message: '请输入有效手机号', trigger: 'blur' }],
        authorizer: [{ required: true, message: '请输入授权联系人', trigger: 'blur' }],
        authorizerPhone: [{ pattern: /^1[3-9]\d{9}$/, message: '请输入有效手机号', trigger: 'blur' }],
        receivableAccount: [{ required: true, message: '请输入公司地址', trigger: 'blur' }],
      },
    },
    //业务表单验证
    businessRules: {
      product_name: [
        { required: true, message: '请输入产品名称', trigger: 'blur' },
      ],
      // brand_or_style: [
      //   { required: true, message: '请输入产品外部款式或牌号', trigger: 'change' },
      // ],
      // internal_brand: [
      //   { required: true, message: '请输入产品内部款式或牌号', trigger: 'change' },
      // ],
      unit_price:[
        { required: true, message: '请输入采购的商品单价', trigger: 'change' },
      ],
      is_quantity_based:[
        { required: true, message: '请选择计价方式', trigger: 'change' },
      ],
      type:[
        { required: true, message: '请输选择类别', trigger: 'change' },
      ],
      signingDate:[
        { required: true, message: '请选择签订合同的时间', trigger: 'change' },
      ],
      validityPeriod:[
        { required: true, message: '请输入合同持续时间', trigger: 'change' },
      ],
    },
    //普通订货成本表单验证
    costRules: {
      supplierName: [
        { required: true, message: '请输入供应商名称', trigger: 'blur' },
      ],
      product_name: [
        { required: true, message: '请输入产品名称', trigger: 'blur' },
      ],
      totalFee: [
        { required: true, message: '请输入订货总成本', trigger: 'blur' },
      ],
    },
    //快捷订货成本表单验证
    simpleCostRules: {
      totalFee: [
        { required: true, message: '请输入订货总成本', trigger: 'blur' },
      ],
    },
    //选择输入名称与字典的方式
    isCommentsupplier:ref(1),
    supplierSource:[
        { value: 1, label: '合作供应商', },
        { value: 2, label: '新增供应商', }
    ],
    //选择输入名称与字典的方式
    isCommentName:ref(1),
    productSource:[
        { value: 1, label: '常购商品', },
        { value: 2, label: '新增商品', }
    ],
    isCommentPat:ref(1),
    patSource:[
        { value: 1, label: '常购款式', },
        { value: 2, label: '新增款式', }
    ],
    //常用商品名称字典
    Name: [
        { value: 1, label: '氧化铝铜板', },
        { value: 2, label: '氧化铝铜管', }
    ],
    //常用款式字典
    PAT: [
        { value: 1, label: 'C15760', },
        { value: 2, label: 'C18150', }
    ],
    //计量方式
    isNumOrWeight:ref(1),
    NumOrWeight:[
        { value: 0, label: '按重量', },
        { value: 1, label: '按数量', }
    ],
    //计价方式
    //计量方式
    isNumOrWeight2:ref(1),
    //型号类别
    isSpecificationType:ref(1),
    specificationType:[
      { value: 1, label: '板类', },
      { value: 2, label: '管类', },
      { value: 3, label: '棒类', },
      { value: 4, label: '镜类', },
      { value: 5, label: '环类', },
      { value: 6, label: '电焊针类', },
      { value: 7, label: '其他类', },
    ],
    //板类
    board:[
      { value: 0, label: '长度', data: null, },
      { value: 1, label: '宽度', data: null, },
      { value: 2, label: '厚度', data: null, },
    ],
    //管类
    pipe:[
      { value: 0, label: '长度', data: null, },
      { value: 1, label: '外径', data: null, },
      { value: 2, label: '内径', data: null, },
    ],
    //棒类
    stick:[
      { value: 0, label: '长度', data: null, },
      { value: 1, label: '直径', data: null, },
    ],
    //镜类
    Lens:[
      { value: 0, label: '直径', data: null, },
      { value: 1, label: '厚度', data: null, },
    ],
    //环类
    ring:[
      { value: 0, label: '内径', data: null, },
      { value: 1, label: '外径', data: null, },
    ],
    //电焊针类
    needle:[
      { value: 0, label: '长度', data: null, },
      { value: 1, label: '主体直径', data: null, },
      { value: 2, label: '偏心直径', data: null, },
    ],
    //重量单位
    weightUnit:[
      { value: 0, label: 'g' },
      { value: 1, label: 'kg' },
      { value: 2, label: 'T' }
    ],
    //数量单位
    quantityUnit:[
      { value: 1, label: 'pcs' },
      { value: 2, label: 'kpcs' }
    ],
    //价格单位（按重量）
    priceWeightUnit:[
      { value: 1, label: '元/g' },
      { value: 2, label: '元/kg' },
      { value: 3, label: '元/T' },
    ],
    //价格单位（按数量）
    priceQuantityUnit:[
      { value: 1, label: '元/pcs' },
      { value: 2, label: '元/kpcs' }
    ],
    //产品类别
    productType:[
      { value: 1, label: '原料' },
      { value: 2, label: '产品' },
      { value: 3, label: '其他' },
    ],
    //规格表（测试用）
    specFields: [
      { dataType: 'string', displayName: '颜色', prefix: 'C', specKey: 'color' },
      { dataType: 'double', displayName: '长度', prefix: 'L', specKey: 'Length' },
      { dataType: 'double', displayName: '宽度', prefix: 'W', specKey: 'width' },
      { dataType: 'double', displayName: '厚度', prefix: 'T', specKey: 'thickness' },
      { dataType: 'double', displayName: '直径/外径', prefix: 'D', specKey: 'diameter' },
      { dataType: 'int', displayName: '层数', prefix: 'l', specKey: 'layer' },
    ],
    //初始化存量数据
    initStockLevel:{
      stock:  null,//重量
      piece: null,//数量
    },
    //实例商品类型的计量方式
    gridData : [
      {
        productType: '原材料',
        method: '按重记',
        example: '铁、铜、带、线、丝等',
      },
      {
        productType: '产品',
        method: '按件记',
        example: '喷嘴、保护镜等小五金件',
      },
      {
        productType: '其他',
        method: '按重按件皆可',
        example: '管、棒、板等大件材料',
      },
    ],
})
export default pageData